import java.lang.Thread;
import java.lang.Math;

public class Test21 {
    public static void main(String[] args) {
        choice ch1 = new choice("北京", 10);
        choice ch2 = new choice("上海", 10);

        Thread t1 = new Thread(ch1);
        Thread t2 = new Thread(ch2);

        t1.start();

        t2.start();
    }
}

class choice implements Runnable {

    private String place;

    private int count;

    public choice() {

    }

    public choice(String place, int count) {
        this.place = place;
        this.count = count;
    }

    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    @Override
    public void run() {
        while (count != 0) {
            System.out.println(place);
            int sleepTime = (int)(Math.random() * 10);
            try {
                Thread.sleep(sleepTime);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                count--;
            }
        }
    }
}